<template>
  <view class="header-box flex-sb">
    <img class="img" src="../static/goback.png" alt="" @click="goback" />
    <view class="header-title">{{title}}</view>
    <view class="slot">
      <slot></slot>
    </view>
  </view>
</template>

<script>
export default {
  name: "lfHeader",
  props: {
    title: {
      type: String,
      default: ""
    }
  },
  data () {
    return {

    };
  },
  methods: {
    CloseAll () {
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isAndroid) {
        //这个是安卓操作系统
        goBack.close('');
      }
      if (isIOS) {
        //这个是ios操作系统
        window.webkit.messageHandlers.iosClose.postMessage(null);
      }
    },
    goback () {
      this.length = history.length
      if (history.length > 1) {
        window.history.go(-1);
      } else {
        this.CloseAll();
      }
      this.$emit('goback')
    }
  }
}
</script>

<style scoped>
.header-box {
  top: 0;
  padding: 15px 15px 5px 15px;
  background-color: #eeeade;
  z-index: 999;
  align-items: center;
}

.img {
  width: 25px;
  height: 25px;
  margin-top: 0 !important;
}
.slot{
  min-width: 25px;
}
</style>